<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改自然灾害题库')" />
    <style>
        .selectDiv{
            margin-left: 20px;
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-zrPaper-add" th:object="${zrPaper}">
        <input name="paperId" th:value="*{id}" th:field="*{id}" type="hidden">
        <div th:each="quest,stat:${zrPaper.list}">

            <div>
                <span th:text="${stat.index}+1"></span>
                <span th:text="${quest.title}"></span>
            </div>
            <div class="selectDiv" th:each="item : ${quest.list}">
                    <input type="radio" class="quest" th:id="${item.id}" th:name="${quest.id}" th:value="${item.selectStr}">
                    <span th:text="${item.selectStr}"></span>、
                    <label th:for="${item.selectStr}" th:text="${item.itemTitle}"></label>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "ziran/zrPaper";
    $("#form-zrQuestionBank-edit").validate({
        focusCleanup: true
    });
    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-zrPaper-add").serializeArray();
            $('input[class="quest"]:checked').each(function(index,value){
                data.push({"name": "list["+index+"].questionBankId", "value": this.name});
                data.push({"name": "list["+index+"].myAnswer", "value": this.value});
            });
            data.push({"name": "paperId", "value": [[${zrPaper.id}]]});
            $.operate.saveTab("/ziran/zrPaperUser" + "/add", data);
        }
    }
</script>
</body>
</html>